<%-- 
    Document   : ChargeDelivery
    Created on : Apr 1, 2012, 3:55:59 PM
    Author     : Tokino
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.CallableStatement"%>
<%@page import="dbhandler.DBConnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1" />
        <META Http-Equiv="Cache-Control" Content="no-cache"/>
        <META Http-Equiv="Cache-Control" Content="no-store"/>
        <META Http-Equiv="Pragma" Content="no-cache"/>
        <META Http-Equiv="Expires" Content="0"/>

        <%
            response.setHeader("Cache-Control", "no-cache, must-revalidate, no-store");
            response.setHeader("Pragma", "no-cache");
            response.setDateHeader("Expires", 0);

        %>
    </head>
    <link rel="stylesheet" href="../style/style.css" type="text/css" id="" media="print, projection, screen" />

    <jsp:useBean id="formChargeValidate" class="servlets.ChargeValidate" scope="request"/>
    <jsp:useBean id="SecprogScopeSession" class=
                 "servlets.SecprogScopeSession" scope="session" />
    <%
        if (SecprogScopeSession.getAccounttype() <= 6 && SecprogScopeSession.getAccounttype() >= 3) {
            response.sendRedirect("../customer/PMain.jsp");
        } else if (SecprogScopeSession.getAccounttype() == 2) {
            response.sendRedirect("../accounting/ACMain.jsp");
        } else if (SecprogScopeSession.getAccounttype() == 10) {
            response.sendRedirect("../admin/AMain.jsp");
        }
        if (!SecprogScopeSession.getIsLogin()) {
            response.sendRedirect("../index.jsp");
        }
        DBConnector dbConnectorchk = null;
        dbConnectorchk = new DBConnector("localhost", 3306, "selector", "53l3ct0r", "bookaholic");
        dbConnectorchk.connectToDB();
        CallableStatement callable = null;
        ResultSet result = null;
    %>
    <body bgcolor="#FFFACD">

        <table width="94%" border="0" align="center">

            <tr >
                <td style="background-color:#FFA500; height:100px">

                </td>
            </tr>
            <tr style="background-color:#FFA500; height:30px" align="center">

                <td><a href="CMain.jsp">Home</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="ViewProduct.jsp">View Product</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href=""></a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="PSettings.jsp">Settings</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="../logout/LogoutProcess.jsp">Logout</a>
                </td>

            </tr>

            <tr style="background-color:#FFA500; height:30px" align="center">

                <td><a href="PSettings.jsp">Change Password</a><font color="#FFFFFF" face="Arial">|</font>

                    <a href="ChargeDelivery.jsp">Charge And Delivery</a>
                    <font color="#FFFFFF" face="Arial">|</font>
                    <a href=""></a>
                </td>

            </tr>

            <tr style="background-color:#FFA500; height:30px" align="center">

                <td><a50>Welcome Customer <%= SecprogScopeSession.getFullName()%><font color="#FFFFFF" face="Arial">|</font>
                Customer since <%= SecprogScopeSession.getDatecreated()%><font color="#FFFFFF" face="Arial">|</font>
                Last Login is <%= SecprogScopeSession.getLastlogin()%></a50>
        </td>

    </tr>

    <tr>
        <td style="padding-top:5%; padding-left:10%; padding-right:10%; padding-bottom:5%; background-color:#EEEEEE;height:auto;width:920px;">
    <a1>Settings</a1><br>
    <%


        CallableStatement callable5 = null;
        ResultSet result5 = null;
        String authCall5 = "{ call select_creditinfo(?) }";
        boolean ctr5=false;
        //Connect to the DB
        dbConnectorchk.connectToDB();
        callable5 = dbConnectorchk.getConnection().prepareCall(authCall5);
        callable5.setString(1, SecprogScopeSession.getUserName());
        result5 = callable5.executeQuery();

        while (result5.next()) {
ctr5=true;
            if (result5.getString("username").equals(SecprogScopeSession.getUserName())) {
             
                formChargeValidate.setDhousenumber(result5.getString("dhousenumber"));
                formChargeValidate.setDstreet(result5.getString("dstreet"));
                formChargeValidate.setDsubdivision(result5.getString("dsubdivision"));
                formChargeValidate.setDcity(result5.getString("dcity"));
                formChargeValidate.setDpostal(result5.getString("dpostal"));
                formChargeValidate.setDcountry(result5.getString("dcountry"));
                
                
                formChargeValidate.setBhousenumber(result5.getString("bhousenumber"));
                formChargeValidate.setBstreet(result5.getString("bstreet"));
                formChargeValidate.setBsubdivision(result5.getString("bsubdivision"));
                formChargeValidate.setBcity(result5.getString("bcity"));
                formChargeValidate.setBpostal(result5.getString("bpostal"));
                formChargeValidate.setBcountry(result5.getString("bcountry"));
                
                formChargeValidate.setFirstName(result5.getString("firstName"));
                formChargeValidate.setLastName(result5.getString("lastName"));
                formChargeValidate.setMiddleInitial(result5.getString("middleInitial"));
                formChargeValidate.setCreditcardnumber(result5.getString("creditcardnumber"));
                formChargeValidate.setCreditcardtype(result5.getString("creditcardtype"));
                formChargeValidate.setCreditcardexpiration(result5.getString("creditcardexpiration"));
                
            }

        }
        if(ctr5==false)
        out.print("<a53>No Credit Info Yet</a53><br>");
    %>
    <a53><%=formChargeValidate.getErrorMsg("status")%></a53><br>
    <a2>Delivery Address</a2><br>

    <form name="ChageDeliveryForm" method="post" action="ChargeValidationProcess.jsp">
        <table>
            <tr>
                <td><a50>House/Apartment#:  </a50></td>
            <td><input type="text" name="dhousenumber" value="<%=formChargeValidate.getDhousenumber()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("dhousenumber")%></a52></td>
            </tr>
            <tr>
                <td><a50>Street:  </a50></td>
            <td><input type="text" name="dstreet" value="<%=formChargeValidate.getDstreet()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("dstreet")%></a52></td>
            </tr>
            <tr>
                <td><a50>Subdivision:  </a50></td>
            <td><input type="text" name="dsubdivision" value="<%=formChargeValidate.getDsubdivision()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("dsubdivision")%></a52></td>
            </tr>
            <tr>
                <td><a50>City:  </a50></td>
            <td><input type="text" name="dcity" value="<%=formChargeValidate.getDcity()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("dcity")%></a52></td>
            </tr>
            <tr>
                <td><a50>Postal:  </a50></td>
            <td><input type="text" name="dpostal" value="<%=formChargeValidate.getDpostal()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("dpostal")%></a52></td>
            </tr>


            <tr>
                <td><a50>Country:  </a50></td>
            <td>
                <select name="dcountry" >
                    <option value="0" <% if (formChargeValidate.getDcountry().equals("0")) {
                            out.print("SELECTED");
                        }%> >- Select Country -</option>
                    <%

                        String authCall = "{ call view_country() }";
                        callable = dbConnectorchk.getConnection().prepareCall(authCall);
                        result = callable.executeQuery();
                        int ctr = 0;
                        while (result.next()) {

                    %>
                    <option value="<%=result.getString("countryname")%>" <%
                        if (formChargeValidate.getDcountry().equals(result.getString("countryname"))) {
                            out.print("SELECTED");
                        }
                            %> ><%=result.getString("countryname")%></option>
                    <%
                        }

                    %>              
                </select> 
            <br><a52><%=formChargeValidate.getErrorMsg("dcountry")%></a52>
            </td>
            </tr>


            <tr><td><a2>Billing Address</a2></td></tr>

            <tr>
                <td><a50>House/Apartment#:  </a50></td>
            <td><input type="text" name="bhousenumber" value="<%=formChargeValidate.getBhousenumber()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("bhousenumber")%></a52></td>
            </tr>
            <tr>
                <td><a50>Street:  </a50></td>
            <td><input type="text" name="bstreet" value="<%=formChargeValidate.getBstreet()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("bstreet")%></a52></td>
            </tr>
            <tr>
                <td><a50>Subdivision:  </a50></td>
            <td><input type="text" name="bsubdivision" value="<%=formChargeValidate.getBsubdivision()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("bsubdivision")%></a52></td>
            </tr>
            <tr>
                <td><a50>City:  </a50></td>
            <td><input type="text" name="bcity" value="<%=formChargeValidate.getBcity()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("bcity")%></a52></td>
            </tr>
            <tr>
                <td><a50>Postal:  </a50></td>
            <td><input type="text" name="bpostal" value="<%=formChargeValidate.getBpostal()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("bpostal")%></a52></td>
            </tr>



            <tr>
                <td><a50>Country:  </a50></td>
            <td>
                <select name="bcountry" >
                    <option value="0" <% if (formChargeValidate.getDcountry().equals("0")) {
                            out.print("SELECTED");
                        }%> >- Select Country -</option>
                    <%


                        CallableStatement callable2 = null;
                        ResultSet result2 = null;
                        String authCall2 = "{ call view_country() }";
                        callable2 = dbConnectorchk.getConnection().prepareCall(authCall2);
                        result2 = callable2.executeQuery();

                        while (result2.next()) {

                    %>
                    <option value="<%=result2.getString("countryname")%>" <%
                        if (formChargeValidate.getBcountry().equals(result2.getString("countryname"))) {
                            out.print("SELECTED");
                        }
                            %> ><%=result2.getString("countryname")%></option>
                    <%
                        }

                    %>              
                </select>   
            <br><a52><%=formChargeValidate.getErrorMsg("bcountry")%></a52>
            </td>
            </tr>




            <tr><td><a2>Credit Information</a2></td>
            <td><a2>Name on Card</a2></td>
            </tr>

            <tr>
                <td><a50>*First Name: </a50></td>
            <td><input type="text" name="firstName" value='<%=formChargeValidate.getFirstName()%>'/>
            <br><a52><%=formChargeValidate.getErrorMsg("firstName")%></a52></td>
            </tr>
            <tr>
                <td><a50>*Last Name: </a50></td>
            <td><input type="text" name="lastName" value='<%=formChargeValidate.getLastName()%>'/>
            <br><a52><%=formChargeValidate.getErrorMsg("lastName")%></a52></td>
            </tr>
            <tr>
                <td><a50>*Middle Initial: </a50></td>
            <td><input type="text" name="middleInitial" value='<%=formChargeValidate.getMiddleInitial()%>'/>
            <br><a52><%=formChargeValidate.getErrorMsg("middleInitial")%></a52></td>
            </tr>    


            <tr>
                <td><a50>Credit Card Number: </a50></td>
            <td><input type="text" name="creditcardnumber" value="<%=formChargeValidate.getCreditcardnumber()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("creditcardnumber")%></a52></td>
            </tr>
            <tr>
                <td><a50>Type: </a50></td>
            <td>                <select name="creditcardtype" >
                    <option value="0" <% if (formChargeValidate.getCreditcardtype().equals("0")) {
                            out.print("SELECTED");
                        }%> >- Select Card Type -</option>

                    <option value="MasterCard" <%
                        if (formChargeValidate.getCreditcardtype().equals("MasterCard")) {
                            out.print("SELECTED");
                        }
                            %>  >MasterCard</option>
                    <option value="Visa"  <%
                        if (formChargeValidate.getCreditcardtype().equals("Visa")) {
                            out.print("SELECTED");
                        }
                            %> >Visa</option>
                </select>   
            <br><a52><%=formChargeValidate.getErrorMsg("creditcardtype")%></a52></td>
            </tr>
            <tr>
                <td><a50>Expiration:  </a50></td>
            <td><input type="text" name="creditcardexpiration" value="<%=formChargeValidate.getCreditcardexpiration()%>"/>
            <br><a52><%=formChargeValidate.getErrorMsg("creditcardexpiration")%></a52></td>
            </tr>

            <tr>
                <td><a50><input type="submit" name="bt_update" value="Update"/></a50></td>

            </tr>
        </table>
    </form>







    username is <%= SecprogScopeSession.getUserName()%>
    Session  is <%= SecprogScopeSession.getIsLogin()%>
    accounttype  is <%= SecprogScopeSession.getAccounttype()%>
    Session  is <%= SecprogScopeSession.getSessionid()%>

</td>
</tr>

<tr>
    <td colspan="2" style="background-color:#FFA500;text-align:center;">
        Copyright © 2011</td>
</tr>
</table>

</body>
</html> 